package obecto.task.wrapper
{
	import flash.utils.setTimeout;
	
	import obecto.task.ITask;

	/**
	 * <code>SingleExecutionTask</code> is a wrapper for an <code>ITask</code> that should be 
	 * executed only once. If started for a second time it will immediately dispatch 
	 * <b><i>completed</i></b>-event.
	 */
	public class SingleExecutionTaskWrapper extends TaskWrapper
	{
		private var executed : Boolean = false;
				
		public function SingleExecutionTaskWrapper(task : ITask) : void
		{
			super(task);
		}
				
		override protected function startActual() : void 
		{
			if(!executed)
			{
				super.startActual();				
			}
			else
			{
				setTimeout(complete, 5);
			}
		}		
	}
}